import Vue from "vue";
import Router from "vue-router";
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from "../views/layout/Layout";

const _import = require("./_import_" + process.env.NODE_ENV);
Vue.use(Router);
export const constantRouterMap = [{
  path: "/login",
  component: _import("login/index"),
  hidden: true
},
{
  path: "/404",
  component: _import("404"),
  hidden: true
},
];
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap

});
// const createRouter = () => new Router({
//   routes: []
// })
// const router = createRouter()

// export function resetRouter() {
//   const newRouter = createRouter()
//   router.matcher = newRouter.matcher // the relevant part
// }
export const asyncRouterMap = [
  // {
  //   path: '/system',
  //   component: Layout,
  //   redirect: '/system/article',
  //   name: '功能模块',
  //   meta: {title: '功能模块', icon: 'tree'},
  //   children: [
  //     {
  //       path: 'article',
  //       name: '文章',
  //       component: _import('article/article'),
  //       meta: {title: '文章', icon: 'example'},
  //       menu: 'article'
  //     },
  //   ]
  // },

  {
    path: "",
    component: Layout,
    name: "订单",
    hidden:false,
    meta: {title: '订单'},
    children: [{
      name:"订单列表",
      path: "order",
      component: _import("order/list"),
      menu: 'order',
      meta: {title: '订单列表'},
    }]
  }
  ,
  {
    path: "",
    component: Layout,
    name: "用户",
    hidden:false,
    meta: {title: '用户'},
    children: [{
      name: "用户列表",
      path: "user",
      component: _import("user/list"),
      menu: 'user',
      meta: {title: '用户列表'},
    }]
  },
  {
    path: "",
    component: Layout,
    name: "产品",
    hidden:false,
    meta: {title: '产品'},
    children: [{
      name: "产品列表",
      path: "product",
      component: _import("product/list"),
      menu: 'product',
      meta: {title: '产品列表'},
    }]
  },
  {
    path: "",
    component: Layout,
    name: "客服",
    hidden:false,
    meta: {title: '客服'},
    children: [{
      name: "客服列表",
      path: "operator",
      component: _import("operator/list"),
      menu: 'operator',
      meta: {title: '客服列表'},
    }]
  },
  {
    path: "*",
    redirect: "/404",
    hidden: true
  }
];
